<?php

/**
 * IPlugin
 *
 * Any class extending IPlugin will have all its methods (except for the constructors
 * and methods beginning with an underscore) added as listeners to the Observer.
 *
 * Warlock is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 *
 * @package    warlock
 * @author     David Cole <neophyte@sourcetutor.com>
 * @license    GNU/GPL v2
 */

class IPlugin extends Object
{
    /**#@+
     * Required Core Objects
     *
     * These are references to the core objects required by this
     * class.
     *
     * @access private
     * @var    object
     */
    var $_Observer;
    var $_Error;
    /**#@-*/

    function __construct()
    {
        // Grab reference to required core objects
        $this->_Observer = &Vault::Get('Observer');
        $this->_Error    = &Vault::Get('Debug_Error');
        
        /*
         * Iterate over the class methods adding them
         * as listeners to Observer when appropriate
         */

        $events = get_class_methods($this);
        $ignore = array('object', 'iplugin', get_class($this));
        
        for ($i = 0, $max = count($events); $i < $max; $i++)
        {
            if ((!in_array($events[$i], $ignore)) && ($events[$i][0] != '_'))
            {
                $this->_Error->Log('Plugin['.get_class($this).'] :: Hooking Event \''.$events[$i].'\'', W_LOG_DEBUG);
                $this->_Observer->AddListener($events[$i], array(&$this, $events[$i]));
            }
        }
    }
}

?>